package com.cskaoyan.market.service.impl;

import com.cskaoyan.market.db.mapper.MarketStatMapper;
import com.cskaoyan.market.service.AdminStatService;
import com.cskaoyan.market.util.MybatisUtil;
import com.cskaoyan.market.vo.StatGoodsVo;
import com.cskaoyan.market.vo.StatOrderVo;
import com.cskaoyan.market.vo.StatUserVo;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class AdminStatServiceImpl implements AdminStatService {
    @Override
    public List<StatOrderVo> order() {
        SqlSession session = MybatisUtil.getSession();
        MarketStatMapper statMapper = session.getMapper(MarketStatMapper.class);
        List<StatOrderVo> statOrderVos = statMapper.selectOrderByUpdateTime();
        session.commit();
        session.close();
        return statOrderVos;
    }

    @Override
    public List<StatGoodsVo> goods() {
        SqlSession session = MybatisUtil.getSession();
        MarketStatMapper mapper = session.getMapper(MarketStatMapper.class);
        List<StatGoodsVo> statGoodsVos = mapper.selectOrderGoodsByUpdateTime();
        session.commit();
        session.close();
        return statGoodsVos;
    }

    @Override
    public List<StatUserVo> user() {
        SqlSession session = MybatisUtil.getSession();
        MarketStatMapper mapper = session.getMapper(MarketStatMapper.class);
        List<StatUserVo> statUserVos = mapper.selectUserByAddTime();
        session.commit();
        session.close();
        return statUserVos;
    }
}
